package com.github.wxiaoqi.security.auth.util.client;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import com.github.wxiaoqi.security.auth.config.JwtProperties;
import com.github.wxiaoqi.security.common.jwt.IJWTInfo;
import com.github.wxiaoqi.security.common.jwt.JWTHelper;

/**
 * Created by ace on 2017/9/10.
 */
@Configuration
public class ClientTokenUtil {

    @Autowired
    private JwtProperties jwtProperties;

    public String generateToken(IJWTInfo jwtInfo) throws Exception {
        return JWTHelper.generateToken(jwtInfo, jwtProperties.getServicePriKey(), jwtProperties.getExpire());
    }

    public IJWTInfo getInfoFromToken(String token) throws Exception {
        return JWTHelper.getInfoFromToken(token, jwtProperties.getServicePubKey());
    }

}
